#include <bits/stdc++.h>

using namespace std;

//CSP-2
//n, m, L, T carnumber, camnumber, roadLength, T maxSpeed
// first find the speed of every car in each cam
//the distance = startSpeed * time + velocity* time^2 / 2
// speed = sprt(startSpeed^2 + 2*a* distance)

struct car{
    int startDis;
    int startSpeed;
    int velocity;
    vector<double> inSpeed; //In each cam;
};

int dfs(vector<vector<int>>& v, vector<int>& a, int t, int l, vector<int>& c){
    if(c == a) return t;
    int temp = 1e9,le=0;
    for(int i=0;i<v.size();i++){
        vector<int> te = v[i];
        v.erase(v.begin()+i);
        vector<int> b =a;
        for(int j=0;j<te.size();j++){
            if(te[j]) b[j] = 1;
        }
        temp = min(temp, dfs(v, b, t+1, le, c));
        v.insert(v.begin()+i,te);
    }
    return temp;

}

int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);

    int Times;

    cin>>Times;
    while(Times --){
        int n,m,L,T,sT,candelete=0;
        cin>>n>>m>>L>>T;
        sT = T*T; //square of Max Speed
        vector<car> cars(n);
        vector<vector<int>> theCarsAtoneCam(m,vector<int>(n,0));
        vector<int> cams(m);
        vector<int> overSpeedCar(n, 0);
        for(int i=0;i<n;i++){
            int s,d,v;
            cin>>d>>s>>v;
            cars[i].startSpeed = s;
            cars[i].startDis = d;
            cars[i].velocity = v;
        }
        vector<int> a(n,0), b(n,0);
        for(int i=0;i<m;i++){
            int distance, overcount=0;
            cin>>distance;
            for(int j=0;j<n;j++){
                car c = cars[j];
                if(c.startDis > distance){
                    c.inSpeed.push_back(0);
                    continue;
                }

                //calc the each car speed at each cams, using the formula from the quesiton
                double inSpeed = pow(c.startSpeed,2)+2*c.velocity*(distance-c.startDis);
                c.inSpeed.push_back(inSpeed);


                if(inSpeed > sT){ // if is bigger than the max speed, mean that this can cant be delete
                    overSpeedCar[j]++;
                    theCarsAtoneCam[i][j] = 1;
                    a[j] = 1;
                }
            }


            cams[i] = distance;
        }
        int OverSpeedCarN = 0;
        for(int &i : overSpeedCar){
            if(i){
                OverSpeedCarN ++ ;
            }
        }
        vector<int> c(n,0);

        cout<<OverSpeedCarN << " "<<m-dfs(theCarsAtoneCam,c, 0, n, a)<<endl;

    }


    return 0;
}
